package com.java.tutorials.jdk7.exceptioncatch;
import java.util.InputMismatchException;
/**
 * Created by xuzhike on 2016/1/23.
 * http://www.java2s.com/Code/Java/JDK-7/CatchingMultipleExceptionTypesToImproveTypeHandling.htm
 * Catching Multiple Exception Types To Improve Type Handling
 */
public class MultipleExceptionCatchingTest {
    public static void main(String[] args) {

        try {
            System.out.print("Enter a number: ");
            int number = 9;
            if (number < 0) {
                throw new InvalidParameter();
            }
            if (number > 10) {
                throw new AssertionError("Number was too big", new Throwable(
                        "Throwable assertion message"));
            }
        } catch (InputMismatchException | InvalidParameter e) {
            e.addSuppressed(new Throwable());
            System.out.println("Invalid input, try again");
        } catch (final Exception e) {
            System.out.println("Invalid input, try again");
        }
    }
}
class InvalidParameter extends java.lang.Exception {
    public InvalidParameter() {
        super("Invalid Parameter");
    }
}